home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 593 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.6 KB  |  62 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Who gets out of memory exception?
  5. Followup-To: comp.std.c++
  6. Date: 29 Feb 1996 16:00:42 GMT
  7. Organization: GABI Software, Sarl.
  8. Approved: clamage@eng.sun.com (comp.std.c++)
  9. Message-ID: <KANZE.96Feb29160957@gabi.gabi-soft.fr>
  10. References: <TOM.96Feb28161011@amber.ssd.csd.harris.com>
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: gabi.gabi-soft.fr
  14. In-Reply-To: tom@ssd.hcsc.com's message of 28 Feb 1996 13:18:52 PST
  15. Content-Length: 1657
  16. X-Lines: 35
  17. Originator: clamage@taumet
  18.  
  19. In article <TOM.96Feb28161011@amber.ssd.csd.harris.com> tom@ssd.hcsc.com
  20. (Tom Horsley) writes:
  21.  
  22. |> Someone showed me the "function try blocks" in the draft standard today, and
  23. |> I immediately began to wonder what happens if the function in question is
  24. |> a constructor and one of the exceptions I catch is "out of memory". If I
  25. |> have something like:
  26.  
  27. |> Fred::Fred(...) try : initializers... {
  28. |>    code goes here...
  29. |> } catch ...
  30.  
  31. |> And then I say "new Fred" and run out of memory.
  32.  
  33. |> I know some existing C++ implementations call the memory allocation code from
  34. |> inside the constructor and others call it from the place in the code where
  35. |> 'new' was invoked. So in different implementations today, the exception
  36. |> might actually occur in the caller or the constructor itself.
  37.  
  38. Where the compiler actually generates the call to the memory allocator
  39. is irrelevant.  The compiler is required to generate code whose
  40. `observable behavior' is as if the call to the memory allocator preceded
  41. the call to operator new.
  42.  
  43. |> Does the standard say who gets the memory exception? Or is running out of
  44. |> memory even an exception? Or is this simply left undefined?
  45.  
  46. The exception (bad_alloc) is thrown by operator new.  The first place it
  47. becomes catchable is in the new expression.  The constructor is never
  48. called (as far as the observable behavior is concerned).
  49. -- 
  50. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  51. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  52. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  53.               -- A la recherche d'une activitΘ dans une region francophone
  54.  
  55.  
  56. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your
  57.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  58.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  59.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  60.   Comments? mailto:std-c++-request@ncar.ucar.edu
  61. ]
  62.